﻿using Curry.Forum.Command.Handler.AutoFac;
using Curry.Forum.Command.Handler.CommandHandler;
using Curry.Forum.Facade;
using Curry.Forum.Facade.BasicRequest;
using Curry.Forum.Facade.Core.Request;
using System.Web.Http;

namespace Curry.Forum.Api.Controllers
{
    [RoutePrefix("api/Article")]
    public class ArticleController : BaseApiController
    {
        /// <summary>
        /// 不支持Get方法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("Get")]
        public string Get()
        {
            return "不支持";
        }

        [HttpPost]
        [Route("GetAllArticle")]
        public BasicResponse GetAllArticle(ArticleRequest req)
        {
            return AutofacExt.GetFromFac<ArticleHandler>().GetAllArticle(req.PageIndex, req.PageSize);
        }


        [HttpPost]
        [Route("GetArticleById")]
        public BasicResponse GetArticleById([FromBody]ArticleBasicRequest req)
        {
            return AutofacExt.GetFromFac<ArticleHandler>().GetArticleById(req.Id);
        }

        [HttpPost]
        [Route("CreateArticle")]
        public bool CreateArticle(ArticleInfoRq req)
        {
            return AutofacExt.GetFromFac<ArticleHandler>().Create(req);
        }
    }
}
